package com.zhl.sharding_jdbc_study_demo.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zhl.sharding_jdbc_study_demo.service.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Controller {
    @Autowired
    Service service;

    @RequestMapping("")
    public String index(){
        return "it works";
    }

    @RequestMapping("add")
    public String add(){
        return JSONObject.toJSONString(service.add());
    }

    @RequestMapping("findall")
    public String findall(){
        return JSONArray.toJSONString(service.findall());
    }


}
